package org.springframework.remoting.jsonrpc;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jabsorb.JSONSerializer;
import org.jabsorb.serializer.Serializer;
import org.springframework.beans.factory.FactoryBean;

public class JSONSerializerFactory implements FactoryBean {

	private List<Serializer> serializers = new ArrayList<Serializer>();
	
	private Log logger = LogFactory.getLog(this.getClass());
	
	public Object getObject() throws Exception {
		logger.info("Creating JSONSerializer");
		JSONSerializer serializer = new JSONSerializer();
		for (Serializer aSerializer :serializers)
		{
			serializer.registerSerializer(aSerializer);
		}
		return serializer;
	}

	public Class getObjectType() {
		return JSONSerializer.class;
	}

	public boolean isSingleton() {
		return false;
	}

	public List<Serializer> getSerializers() {
		return serializers;
	}

	public void setSerializers(List<Serializer> serializers) {
		this.serializers = serializers;
	}

}
